const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');

Page({
  
  data: {
    chooseid:1,
    dateString: "",
    spot: [],
    leave: [],
    Supplementary: [],
    absence: [],
    show:false,
    defaultDate:'',
    attendList:[]
  },
  choose(e){
    this.setData({
      chooseid:e.currentTarget.dataset.id
    });
    this.getList();
  },
  dateChange(e) {
    this.setData({
      dateString: e.detail.dateString
    });
    this.getList();
  },
  onLoad: function() {
    this.getList();
    this.getAttendDataList();
  },
  getList() {
		var that = this;
		http.httpPost(config.attendList, {
      dateTime:that.data.dateString,
			type:that.data.chooseid
		}, function(e) {
			if (e.code == 1) {
				that.setData({
					attendList:e.data
        });
			}
		});
  },
  getAttendDataList(){
    var that = this;
		http.httpPost(config.getAttendDataList, {
		}, function(e) {
			if (e.code == 1) {
				that.setData({
					spot:e.data
        });
			}
		});
  },
  toToday() {
    let year = new Date().getFullYear(),
      month = new Date().getMonth() + 1,
      day = new Date().getDate();
    this.setData({
      year,
      day,
      month
    })
  },
  onReady() {
		if (!app.login()) {
			return;
		}
	}
})